package com.example.springboot.config.anotation.conditionOn.conditionOnBean;

import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 测试ConditionalOnBean注解
 *
 * @Author:ChenZhangKun
 * @Date: 2021/5/6 17:44
 */
@Configuration
public class ConditionOnBeanDemo {
    @Bean
    public C c() {
        return new C();
    }

    /**
     * 有name=c的对心才会实例化
     *
     * @return
     */
    @Bean
    @ConditionalOnBean(name = "c")
    public D d() {
        return new D();
    }
}
